﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace GeoFly
{
    public class GIDSInter : IDWInter
    {
        public GIDSInter(StationInfo station)
        {
            m_dCx = 0.0;
            m_dCy = 0.0;
            m_dCe = -0.006;
        }

        GIDSInter(MapExtent extent, double gridresolustion)
        {
            ;
        }



        /// <summary>
        /// 读入DEM图层信息
        /// </summary>
        /// <returns></returns>
        public void ReadInDEM()
        {
            //string title1, title2, strFile;
            //title1 = "ASC文件";
            //title2 = "读入DEM文件";
            //strFile = GetReadFileName(title1, title2, "asc");
            //return m_GridIO.ReadASCByThread(strFile, m_DemGrid);
        }

        /// <summary>
        /// 单站点时序插值结果
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public void SpatialOut(WeatherData data)
        {
            //读入数据
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Title = "输入插值站点位置";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                ReadInStationPos(dlg.FileName);
            }

            dlg.Title = "插值站点气象数据";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                this.ReadInStationValue(dlg.FileName);
            }
            dlg.Title = "请输入DEM高程数据";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                this.m_DemGrid.ReadASC(dlg.FileName);
            }

            //栅格数据结构初始化

            m_gridLayer = HydroSimulate.g_GridLayerPara.g_DemLayer.AttributesCopy();
            

            for (int i = 0; i < 1/*saDate.GetSize()*/; i++)		//逐日循环(因为数据太大，只循环一天的结果)
            {
                for (int j = 0; j < m_gridLayer.rowCount; j++)		//开始新一日的空间插值计算
                {
                    for (int k = 0; k < m_gridLayer.colCount; k++)
                    {
                        //如果DEM位于子流域边界外，不进行运算
                        if (m_DemGrid.Values[j, k] == m_DemGrid.nodata)
                            continue;
                        
                        //当前计算栅格的中心坐标
                        LPoint position = m_gridLayer.CellPosition(j, k);
                        //计算栅格中心和插值节点的距离
                        //CalculateDistance(position.X, position.Y);
                        //double dvalue = CellValue(i, j, k);
                        //m_gridLayer.Values[j, k] = dvalue;
                    }
                }
            }
        }

        
        
        public GridLayer m_DemGrid;
        
        double m_dCx;
        double m_dCy;
        double m_dCe;			
    }

}